<?php


abstract class BaseTblStructurePeer {

	
	const DATABASE_NAME = 'taylor';

	
	const TABLE_NAME = 'tbl_structure';

	
	const CLASS_DEFAULT = 'lib.model.TblStructure';

	
	const NUM_COLUMNS = 15;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const F_ID = 'tbl_structure.F_ID';

	
	const CREATED_ON = 'tbl_structure.CREATED_ON';

	
	const UPDATED_ON = 'tbl_structure.UPDATED_ON';

	
	const F_NAME = 'tbl_structure.F_NAME';

	
	const F_DESCRIPTION = 'tbl_structure.F_DESCRIPTION';

	
	const F_LEVEL = 'tbl_structure.F_LEVEL';

	
	const F_PARENTID = 'tbl_structure.F_PARENTID';

	
	const F_SEQ_NO = 'tbl_structure.F_SEQ_NO';

	
	const F_IMAGE = 'tbl_structure.F_IMAGE';

	
	const F_LINK = 'tbl_structure.F_LINK';

	
	const F_STATUS = 'tbl_structure.F_STATUS';

	
	const F_UPDATED_UID = 'tbl_structure.F_UPDATED_UID';

	
	const F_UPDATED_DATETIME = 'tbl_structure.F_UPDATED_DATETIME';

	
	const F_CREATED_UID = 'tbl_structure.F_CREATED_UID';

	
	const F_CREATED_DATETIME = 'tbl_structure.F_CREATED_DATETIME';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('FId', 'CreatedOn', 'UpdatedOn', 'FName', 'FDescription', 'FLevel', 'FParentid', 'FSeqNo', 'FImage', 'FLink', 'FStatus', 'FUpdatedUid', 'FUpdatedDatetime', 'FCreatedUid', 'FCreatedDatetime', ),
		BasePeer::TYPE_COLNAME => array (TblStructurePeer::F_ID, TblStructurePeer::CREATED_ON, TblStructurePeer::UPDATED_ON, TblStructurePeer::F_NAME, TblStructurePeer::F_DESCRIPTION, TblStructurePeer::F_LEVEL, TblStructurePeer::F_PARENTID, TblStructurePeer::F_SEQ_NO, TblStructurePeer::F_IMAGE, TblStructurePeer::F_LINK, TblStructurePeer::F_STATUS, TblStructurePeer::F_UPDATED_UID, TblStructurePeer::F_UPDATED_DATETIME, TblStructurePeer::F_CREATED_UID, TblStructurePeer::F_CREATED_DATETIME, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id', 'created_on', 'updated_on', 'f_name', 'f_description', 'f_level', 'f_parentid', 'f_seq_no', 'f_image', 'f_link', 'f_status', 'f_updated_uid', 'f_updated_datetime', 'f_created_uid', 'f_created_datetime', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('FId' => 0, 'CreatedOn' => 1, 'UpdatedOn' => 2, 'FName' => 3, 'FDescription' => 4, 'FLevel' => 5, 'FParentid' => 6, 'FSeqNo' => 7, 'FImage' => 8, 'FLink' => 9, 'FStatus' => 10, 'FUpdatedUid' => 11, 'FUpdatedDatetime' => 12, 'FCreatedUid' => 13, 'FCreatedDatetime' => 14, ),
		BasePeer::TYPE_COLNAME => array (TblStructurePeer::F_ID => 0, TblStructurePeer::CREATED_ON => 1, TblStructurePeer::UPDATED_ON => 2, TblStructurePeer::F_NAME => 3, TblStructurePeer::F_DESCRIPTION => 4, TblStructurePeer::F_LEVEL => 5, TblStructurePeer::F_PARENTID => 6, TblStructurePeer::F_SEQ_NO => 7, TblStructurePeer::F_IMAGE => 8, TblStructurePeer::F_LINK => 9, TblStructurePeer::F_STATUS => 10, TblStructurePeer::F_UPDATED_UID => 11, TblStructurePeer::F_UPDATED_DATETIME => 12, TblStructurePeer::F_CREATED_UID => 13, TblStructurePeer::F_CREATED_DATETIME => 14, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id' => 0, 'created_on' => 1, 'updated_on' => 2, 'f_name' => 3, 'f_description' => 4, 'f_level' => 5, 'f_parentid' => 6, 'f_seq_no' => 7, 'f_image' => 8, 'f_link' => 9, 'f_status' => 10, 'f_updated_uid' => 11, 'f_updated_datetime' => 12, 'f_created_uid' => 13, 'f_created_datetime' => 14, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/TblStructureMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.TblStructureMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = TblStructurePeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TblStructurePeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TblStructurePeer::F_ID);

		$criteria->addSelectColumn(TblStructurePeer::CREATED_ON);

		$criteria->addSelectColumn(TblStructurePeer::UPDATED_ON);

		$criteria->addSelectColumn(TblStructurePeer::F_NAME);

		$criteria->addSelectColumn(TblStructurePeer::F_DESCRIPTION);

		$criteria->addSelectColumn(TblStructurePeer::F_LEVEL);

		$criteria->addSelectColumn(TblStructurePeer::F_PARENTID);

		$criteria->addSelectColumn(TblStructurePeer::F_SEQ_NO);

		$criteria->addSelectColumn(TblStructurePeer::F_IMAGE);

		$criteria->addSelectColumn(TblStructurePeer::F_LINK);

		$criteria->addSelectColumn(TblStructurePeer::F_STATUS);

		$criteria->addSelectColumn(TblStructurePeer::F_UPDATED_UID);

		$criteria->addSelectColumn(TblStructurePeer::F_UPDATED_DATETIME);

		$criteria->addSelectColumn(TblStructurePeer::F_CREATED_UID);

		$criteria->addSelectColumn(TblStructurePeer::F_CREATED_DATETIME);

	}

	const COUNT = 'COUNT(tbl_structure.F_ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tbl_structure.F_ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TblStructurePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TblStructurePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = TblStructurePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TblStructurePeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return TblStructurePeer::populateObjects(TblStructurePeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			TblStructurePeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = TblStructurePeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TblStructurePeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(TblStructurePeer::F_ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(TblStructurePeer::F_ID);
			$selectCriteria->add(TblStructurePeer::F_ID, $criteria->remove(TblStructurePeer::F_ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(TblStructurePeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TblStructurePeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof TblStructure) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TblStructurePeer::F_ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(TblStructure $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TblStructurePeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TblStructurePeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(TblStructurePeer::DATABASE_NAME, TblStructurePeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = TblStructurePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(TblStructurePeer::DATABASE_NAME);

		$criteria->add(TblStructurePeer::F_ID, $pk);


		$v = TblStructurePeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(TblStructurePeer::F_ID, $pks, Criteria::IN);
			$objs = TblStructurePeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseTblStructurePeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/TblStructureMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.TblStructureMapBuilder');
}
